package com.jt.thro;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import com.jt.vo.SysResult;

import lombok.extern.slf4j.Slf4j;

//全局异常处理机制
@RestControllerAdvice//只能捕捉controller层的异常，service层的无法捕捉，除非抛给controller层
@Slf4j//映入日志API
public class SysResultControllerAdvice {
	@ExceptionHandler(RuntimeException.class)
	public SysResult sysResultException(Exception e) {
		//常见写法
		e.printStackTrace();
		log.error("服务器异常"+e.getMessage());
		return SysResult.fail();
	}
}
